
<include file='__PUBLIC__/frame.html' />
<script type="text/javascript" src="__STATIC__/uploadify/jquery-1.8.2.min.js"></script>

<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

<link href="__STATIC__/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>

 <script>
 var ue = UE.getEditor('editor');
 </script>
 <script type="text/javascript">
 	$(function(){
 		
 		
 		
 		
 		$(".inputcate ").change(function(){
 			var cid=$(this).val();
 			
 			$.ajax({
 				type:"post",
 				url:"__CONTROLLER__" + "&a=ajax_get_cate",
 				data:{cid:cid},
 				dataType:'json',
 				success:function(data){
 					
 					msg='';
 					gspec='';
 					$.each(data, function(k,v) {
 					if(v.tptype == '属性'){
 						
	 					msg+='<ul style="float:left; overflow: hidden; height: 50px; width: 950px; border: 1px solid #DDDDDD;"><li style="margin-top:10px; width:150px;float: left;"><input type="hidden" name="tpid[]" value="'+v.tpid+'" />'+v.tpname+'</li><li style="float: left;margin-top:10px;width: 600px;"><select style="width: 100px; border: 1px solid #DDDDDD;" name="gpvalue[]"><option value="">请选择</option>'
	 					
	 					$.each(v.tpvalue,function(key,value){
	 						
	 					msg+='<option value="'+value+'">'+value+'</option>'
	 					});
	 					
						msg+='</select><input type="hidden" name="aprice[]" /></li>\
						</ul>'
 					}else{
 						gspec+='<ul style="float:left; overflow: hidden; height: 50px; width: 950px; border: 1px solid #DDDDDD;"><li style="margin-top:10px; width:150px;float: left;"><input type="hidden"  name="tpid[]" value="'+v.tpid+'" />'+v.tpname+'</li><li style="float: left;margin-top:10px;width: 600px;"><select style="margin-right:50px; width: 100px; border: 1px solid #DDDDDD;" name="gpvalue[]"><option value="">请选择</option>'
 					
	 					$.each(v.tpvalue,function(key,value){
	 						
	 					gspec+='<option value="'+value+'">'+value+'</option>'
	 					});
	 					
						gspec+='</select>附加价格<input type="text" name="aprice[]" /><a class="btn btn-info" style="margin-left:50px" href="javascript:;">添加规格</a></li></ul>'
 					}
 					});
	 					$("#gproperty").html(msg);
	 					$("#gspec").html(gspec);
 				}
 			});
 		})
 		$(".btn-info").live('click',function(){
 			$add = $(this).parent().parent().eq(0).clone();
// 			$add.siblings('li').eq(0).html('删除规格');
 			$("#gspec").append($add);
 			
 		})
 		
 	})
 </script>
 
 <style type="text/css">
 	#uploadList2 ul li img{
 		float: right;
 		width: 50px;
 		height: 50px;
 	}
 	#uploadList2 ul li{
 		float: left;
 	}
 </style>

<div class="right">
	<div class="now">
		<div class="now_l"></div>
		<div class="now_m">
			<span class="fl">发布商品</span>
			<span class="fr fabu"><a href="">发布商品</a></span>
		</div>
		<div class="now_r"></div>
		<div class="clear"></div>
	</div>
	<form method="post" enctype="multipart/form-data">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="wenzhang">
	<tr>
		<td width="100" class="bg_f8" align="right">商品名称：</td>
		<td colspan="3"><input type="text" name="gname" value="{$data.gname}" class="inputall input500" maxlength="36" /></td>
		<td rowspan="7" valign="top" width="80">
			<div   style="float: ; width:168px;height: 168px; border:1px solid #ddd; display:block;" />
				<div id="uploadList">
					<ul></ul>
				</div>
			</div>
			<p class="mat5">
			
			<div lab="uploadFile">

            <input id="file" type="file" multiple="true">

            <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>

            <script type="text/javascript">

                $(function() {

                    $('#file').uploadify({

                       'formData'     : {//POST数据

                            '<?php echo session_name();?>' : '<?php echo session_id();?>',

                        },

                        'fileTypeDesc' : '上传文件',//上传描述

                        'fileTypeExts' : '{$set['filetype']}',

                        'swf'      : '__STATIC__/uploadify/uploadify.swf',

                        'uploader' : '{|U:"upload"}',

                        'buttonText':'选择文件',

                        'fileSizeLimit' : '2000KB',

                        'uploadLimit' : 1000,//上传文件数

                        'width':65,

                        'height':25,

                        'successTimeout':10,//等待服务器响应时间

                        'removeTimeout' : 0.2,//成功显示时间

                        'onUploadSuccess' : function(file, data, response) {

                            data=$.parseJSON(data);

                            var imageUrl = data.image?data.url:'__STATIC__/image/default.png';
							
							$('#lthumb').val(data.path);
                            var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"' class='hd-w80 hd-h70'/></li>";

                            $("#uploadList ul").prepend(li);

                        }

                    });

                });

            </script>

            

        </div>

			
			</p>
		</td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">商品分类：</td>
		<td colspan="3">
			<select name="cid" class="inputcate">
						<option value="" >请选择分类</option>
				<foreach from='$cate' key='$k' value='$v'>
						<option value="{$v.cid}" <if value="$data['cid'] eq $v['cid']">selected="selected"</if>>{$v._name}</option>
				</foreach>
			</select> 
			
		</td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">所属品牌：</td>
		<td colspan="3">
			<select name="bid" class="inputselect">
						<option value="" >请选择品牌</option>
				<foreach from='$brand' key='$k' value='$v'>
						<option <if value="$data.bid eq $v.bid">selected</if>  value="{$v.bid}" >{$v.brand}</option>
				</foreach>
			</select>
		</td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">市价场：</td>
		<td width="250"><input type="text" name="mprice" value="{$data.mprice}" class="inputall input100" /> <span class="c888">元</span></td>
		<td width="100" class="bg_f8" align="right">单　　位：</td>
		<td><input type="text" name="unit" value="" class="inputall input100" /></td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">商城价：</td>
		<td colspan="3"><input type="text" name="price" value="{$data.price}" class="inputall input100" /> <span class="c888">元</span></td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">点击次数：</td>
		<td colspan="3"><input type="text" name="click" value="{$data.price}" class="inputall input100" /></td>
	</tr>
	<tr>
		<td class="bg_f8" align="right">商品图册：</td>
		<td colspan="3">
			<div style="float: left;" lab="uploadFile">

            <input id="file2" type="file" name="" multiple="true">

            <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>

            <script type="text/javascript">

                $(function() {

                    $('#file2').uploadify({

                       'formData'     : {//POST数据

                            '<?php echo session_name();?>' : '<?php echo session_id();?>',

                        },

                        'fileTypeDesc' : '上传文件',//上传描述

                        'fileTypeExts' : '{$set['filetype']}',

                        'swf'      : '__STATIC__/uploadify/uploadify.swf',

                        'uploader' : '{|U:"upload"}',

                        'buttonText':'选择文件',

                        'fileSizeLimit' : '2000KB',

                        'uploadLimit' : 1000,//上传文件数

                        'width':65,

                        'height':25,

                        'successTimeout':10,//等待服务器响应时间

                        'removeTimeout' : 0.2,//成功显示时间

                        'onUploadSuccess' : function(file, data, response) {

                            data=$.parseJSON(data);

                            var imageUrl = data.image?data.url:'__STATIC__/image/default.png';
							
                            var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"' class='hd-w80 hd-h70'/><input type='hidden' value='"+data[0]+"' name='sthumb[]' /><input type='hidden' value='"+data[1]+"' name='mthumb[]' /></li>";
							
                            $("#uploadList2 ul").prepend(li);

                        }

                    });

                });

            </script>

            

        </div>
			<div style="float: left;" id="uploadList2">
					<ul></ul>
			</div></td>
	</tr>
	</table>
	<br />
		<h3 style="font-weight: 700;">商品属性</h3>
	<div id="gproperty" style="font-size: 15px;">
		<foreach from="$gproperty" key="$k" value="$v">
		<ul style="float:left; overflow: hidden; height: 50px; width: 950px; border: 1px solid #DDDDDD;">
			<li style="margin-top:10px; width:150px;float: left;">
				{$v.gpvalue}
				<input type="hidden" name="tpid[]" value="" />
			</li>
			<li style="float: left;margin-top:10px;width: 600px;">
				<select style="width: 100px; border: 1px solid #DDDDDD;" name="gpvalue[]">
					<option value="">请选择</option>
		 			<option value="value">{$v.gpvalue}</option>
				</select>
				<input type="hidden" name="aprice[]" />
			</li>
		</ul>
		</foreach>
	</div>
	<br />
		<h3 style="font-weight: 700;">商品规格</h3>
	<div id="gspec" style="overflow: hidden; font-size: 15px;">
		
	</div>
	
	<br />
	<h3 style="font-weight: 700;">商品详情</h3>
	<br />
	
	
	
	<div class="mat5"><script id="editor" type="text/plain" style="width:100%;height:500px;">{$gdata.gdetails}</script>  </div>
	<div class="mat10 center">
		<input type="hidden" id="lthumb" value="" name="lthumb" />
		<input type="submit" value="修 改" class="tjbtn" />
	</div>
	</form>
</div>
<style type="text/css"> 
a.js_add{display:block; float:left; width:120px; height:30px; line-height:30px; text-align:center;background:#76A500; color:#f5f5f5; border-radius:2px; font-family:'宋体'; font-size:14px; font-weight:bold}
a:hover.js_add,a:hover.js_del{background-color:#cccc00;}
a.js_del{width:42px; padding:5px 10px; text-align:center;background:#FF9900; color:#f5f5f5; border-radius:2px; font-family:'宋体'; font-size:12px;}
</style>

		<div class="clear"></div>
	</div>
	<div class="foot">Copyright <span class="num">&copy;</span> 2014-2017 <a target="_blank" href="#"></a> 版权所有</div>

</div>



</body>
</html>	
